﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Automted_Bank_teller
{
    public partial class ClientProfile : Form
    {
        public ClientProfile()
        {
            InitializeComponent();
        }

        private void ClientProfile_Load(object sender, EventArgs e)
        {
            try
            {
                Profile_logic set_profile = new Profile_logic();

                set_profile.Database_ConnectString();
                set_profile.Open_Database();
                set_profile.RetrieveProfileInfo();
                set_profile.GetProfileInfo();

                txt_clientProfile_fname.Text = set_profile.return_fname();
                txt_clientProfile_Mname.Text = set_profile.return_mName();
                txt_clientProfile_Lname.Text = set_profile.return_lname();
                txt_clientProfile_address.Text = set_profile.return_address();
                txt_clientProfile_City.Text = set_profile.return_city();
                txt_clientProfile_Email.Text = set_profile.return_email();
                txt_clientProfile_government.Text = set_profile.return_government();
                txt_clientProfile_phoneNumber.Text = set_profile.return_phone();
                txt_clientProfile_AccountBalance.Text = set_profile.return_balance().ToString();
                txt_clientProfile_SSN.Text = set_profile.retun_ssn();
                txt_clientProfile_ClientID.Text = set_profile.return_cId();
            }catch(Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }

            
        }

        private void BTN_clientProfile_SaveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                Profile_logic client_profile = new Profile_logic();
                client_profile.Database_ConnectString();
                client_profile.GetUpdatedINfoFromClient(txt_clientProfile_phoneNumber.Text, txt_clientProfile_Email.Text, txt_clientProfile_City.Text, txt_clientProfile_government.Text, txt_clientProfile_address.Text);
                client_profile.UpdateProfileInfo();
                client_profile.Open_Database();
                client_profile.ExecuteQuery();
                client_profile.makeSureDataUpdated();
                client_profile.Close_Database();
            }catch(Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }

        private void BTN_clientProfile_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
